import com.alibaba.fastjson.JSONObject;

import java.util.*;

public class StringCalculate {
    public static String addStrings(String num1, String num2) {
        StringBuilder result = new StringBuilder();
        int carry = 0; // 进位初始化为0

        int i = num1.length() - 1;
        int j = num2.length() - 1;

        while (i >= 0 || j >= 0) {
            int x = (i >= 0) ? num1.charAt(i) - '0' : 0;
            int y = (j >= 0) ? num2.charAt(j) - '0' : 0;
            int sum = x + y + carry;
            carry = sum / 10; // 计算进位
            result.append(sum % 10); // 添加当前位的数字到结果字符串
            i--;
            j--;
        }

        if (carry > 0) {
            result.append(carry); // 如果最高位有进位，添加进位到结果字符串
        }

        return result.reverse().toString(); // 最后需要反转字符串得到正确的结果
    }

    public static List<List<Integer>> findZeroSumArray(List<Integer> arr1,List<Integer> arr2) {
        List<List<Integer>> result = new ArrayList<>();
        for (int num : arr2) {
            List<Integer> resultList = new ArrayList<>();
            if (arr1.contains(-num)) {
                resultList.add(num);
                resultList.add(-num);
                result.add(resultList);
            }
        }
        return result;
    }


    public static void main(String[] args) {
        List<Integer> arr1 = Arrays.asList(1, 2, 3, -2, -1,-1);
        List<Integer> arr2 = Arrays.asList(-3, 4, -2, 1, 5);
        List<List<Integer>> zeroSumArray = findZeroSumArray(arr1, arr2);
        System.out.println(JSONObject.toJSONString(zeroSumArray));
    }
}
